package org.lingshi.shopping_manager_api.security;

import cn.dev33.satoken.stp.StpInterface;
import org.apache.dubbo.config.annotation.DubboReference;
import org.lingshi.common.entity.Permission;
import org.lingshi.common.service.IAdminService;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

@Component
public class StpInterfaceImpl implements StpInterface {
    @DubboReference
    private IAdminService adminService;

    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        List<Permission> allPermission = adminService.findAllPermission((String) loginId);

        List<String> permissions = allPermission.stream().map(Permission::getUrl).collect(Collectors.toList());

        System.out.println("permissions="+ permissions);

        return permissions;
    }

    @Override
    public List<String> getRoleList(Object o, String s) {
        return null;
    }
}
